{% extends "home.html" %}

{#
 - $Id: rfc4193.html 7557b5d4d82b 2012/12/02 09:07:16 pgurumur $
 - Copyright (c) 2009 Prabhu Gurumurthy  <pgurumur@gmail.com>
 - 
 - Permission to use, copy, modify, and distribute this software for any
 - purpose with or without fee is hereby granted, provided that the above
 - copyright notice and this permission notice appear in all copies.
 -
 - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#}

{# $Revision: 7557b5d4d82b $ #}
{# $Author: pgurumur $ #}

{% block djanet_title %} RFC 4193 {% endblock %}
{% block tabtitle %} RFC 4193 {% endblock %}

{% block djanet_content_script %}
<script type = "text/javascript">
   $("#id_address").attr("size", "40");
   $("#rfc4193form").submit(function(event) {
      event.preventDefault();
      var $form = $(this);
      var action = $form.attr("action");
      var length = $("#id_length").val()
      var prefix = $("#id_prefix").attr("checked");
      var type = $("#id_prefixtype").val()
      var desc = $("#id_description").val()
      var add = $("#id_addssn").attr("checked");
      var entity = $("#id_entity").val()
      var usedby = $("#id_usedby").val()
      var insert = $("#id_insert").attr("checked");
      $.post(action, { length: length, prefix: prefix, prefixtype: type,
         description: desc, addssn: add, entity: entity, usedby: usedby,
         insert: insert },
         function(data, textstatus) {
            if (data.success == true) {
               $("#id_address").val(data.address);
            }
            else {
               console.log(data.error);
            }
         }, "json");

      return false;
   });

   $("#clripv6").click(function() { 
         $("#id_prefix").attr("checked", false);
         $("#id_length").val("64");
         $("#id_prefixtype").val("None");
         $("#id_description").val("");
         $("#id_addssn").attr("checked", false);
         $("#id_entity").val("None");
         $("#id_usedby").val("None");
         $("#id_insert").attr("checked", false);
         $("#id_address").val("");

         return false;
         }
   );

</script>
{% endblock %}

{% block djanet_content %}
<div id = rfc4193" title = "Generate IPv6 address" align = "center">
   <h2> Generate RFC4193 IPv6 address/prefix </h2>
   <form id = "rfc4193form" action = {{ ipv6_action }} method = POST>
      {% csrf_token %}
      <table>
         {{ rfcform.as_table }}
         <tr>
            <td align = "right">
               <p>
               <input type = "submit" value = "Get Address"/>
               <button id = "clripv6">Clear</button>
               </p>
            </td>
         </tr>
      </table>
   </form>
</div>

{% endblock %}
